﻿Imports VendasBLL
Imports FinanceiroBLL.ContasPagarBLL
Imports FinanceiroBLL.ContasBLL
Public Class InicioUC
    Dim PrimeiroDiaMes As Date
#Region "Load"
    Private Sub InicioUC_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Dim ObjAgen As New AgendamentoBLL    '  Me.DGVDados.CurrentRow.Selected = False 'tira a seleção da primeira linha da dgvdados
        Try
            DGVAgendamento.DataSource = ObjAgen.locdata(Date.Now, Date.Now)
            Me.DGVAgendamento.RowHeadersVisible = False
            data()
            chart()
            contaspagar()
        Catch ex As Exception
        Finally
            ObjAgen = Nothing
        End Try
    End Sub
#End Region
#Region "Pre paint"
    Private Sub DGVAgendamento_RowPrePaint(sender As System.Object, e As System.Windows.Forms.DataGridViewRowPrePaintEventArgs)
        If Date.Parse(DGVAgendamento.Rows(e.RowIndex).Cells("age_data").Value) = Date.Now.ToShortDateString Then
            If DGVAgendamento.Rows(e.RowIndex).Cells("age_horainicio").Value.ToString > DateTime.Now.ToShortTimeString Then
                DGVAgendamento.Rows(e.RowIndex).DefaultCellStyle.ForeColor = Color.LightGreen
            Else
                DGVAgendamento.Rows(e.RowIndex).DefaultCellStyle.ForeColor = Color.Tomato
            End If
        ElseIf DGVAgendamento.Rows(e.RowIndex).Cells("age_data").Value > Date.Now Then
            DGVAgendamento.Rows(e.RowIndex).DefaultCellStyle.ForeColor = Color.LightGreen
        Else
            DGVAgendamento.Rows(e.RowIndex).DefaultCellStyle.ForeColor = Color.Tomato
        End If
    End Sub
#End Region
#Region "Gráfico"
    Sub chart()
        Dim objBLL As New FinanceiroBLL.ContasBLL
        Try
            Chart1.DataSource = objBLL.fluxodecaixa(PrimeiroDiaMes, Date.Now.ToShortDateString)
            Chart1.DataBind()
        Catch ex As Exception

        End Try
    End Sub
#End Region
#Region "Data"
    Sub data()
        Dim dataInicio As Date = Date.Now.ToShortDateString()
        ' dataInicio = CDate("10/5/2010")
        PrimeiroDiaMes = "01/" & Month(dataInicio) & "/" & Year(dataInicio)
    End Sub
#End Region
#Region "Contas a pagar"
    Sub contaspagar()
        Dim objBLL As New FinanceiroBLL.ContasPagarBLL
        DGVDados.DataSource = objBLL.buscar(Date.Now.ToShortDateString, 1)
        DGVDados.Refresh()
    End Sub
#End Region

End Class
